﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
        public class AB05AV95NReport : BaseReport
    {
            string strCompany = "HLT",strExcelFile = "";
            public string StandardType = "";
        public AB05AV95NReport()
            : base()
        {
        }
        public AB05AV95NReport(Dictionary<string, object> dicParamater)
            : base(dicParamater)
        {
            columns.Add("STATUS"); 
            columns.Add("ICCABSFACTORY"); 
            columns.Add("FORDERNO"); 
            columns.Add("ICCABSIDAT"); 
            columns.Add("ARTICLE"); 
            columns.Add("FINISHING"); 
            columns.Add("ICCABSDPART"); 
            columns.Add("ICCABSIPCNUM"); 
            columns.Add("ICCABSIQTY"); 
            columns.Add("ICCABSRDAT"); 
            columns.Add("ICCABSRPCNUM"); 
            columns.Add("ICCABSRQTY"); 
            columns.Add("RATE"); 
            strCompany = dicParamater["Company"].ToString().Trim();
            strExcelFile = dicParamater["ExcelFile"].ToString().Trim();
         
        }
        public void FillInExcelData(ArrayList columns, DataSet setSoruce, int xStart = 2, int yStart = 1)
        {
            try
            {               
                int x = xStart, y = yStart;
                DataTable dtSoruce = setSoruce.Tables["ABPOS"];
                foreach (DataRow dataRow in dtSoruce.Rows)
                {
                    y = yStart;
                    foreach (string column in columns)
                    {
                        exAgent.SetCellValue(x, y, dataRow[column].ToString());
                        y++;
                    }
                    x++;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void WriteExcelReport(string fileType)
        {
            Queue CellQueue = new Queue();

            string filename = "";
            string sheetName = "";
            string Standard = "AB05AV95N";
            strExcelFile = @"HLT\HLTPlanningReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = strCompany;
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Planning\后整理\后整理订单状态" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInExcelData(columns, dsSource, 3, 1);
            base.WriteExcelReport(fileType);
            
        }
    }

}
